﻿using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Configuration;
using DropBoxClient.Entities;
using System.Collections.Generic;
using System.IO;

namespace DropBoxClient.Tests
{
    [TestClass]
    public class RestoreTest
    {
        private string accessToken;

        [TestInitialize]
        public void Init()
        {
            accessToken = ConfigurationManager.AppSettings["AccessToken"];
        }

        public TestContext TestContext { get; set; }

        [TestMethod]
        [DeploymentItem("Data\\Notes2.txt")]
        public void Restore_ResultIsNotNull()
        {
            var client = new OAuth2Client(accessToken);
            var inputFilePath = Path.Combine(TestContext.DeploymentDirectory, "Notes2.txt");
            client.PutFiles(StringConstants.SandboxRoot, "Test/Notes.txt", inputFilePath);
            var revisionList = client.GetRevisions(StringConstants.SandboxRoot, "Test/Notes.txt");
            var revision = revisionList[revisionList.Count - 2].Rev;
            var meta = client.Restore(StringConstants.SandboxRoot, "Test/Notes.txt", revision);
            Assert.IsNotNull(meta);
        }
    }
}
